package prototype;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by thiswhyme on 2019/03/16
 */
public class Eclipse extends DevTool implements Cloneable, Serializable {

    private String officialWebsite;

    private List<Plugin> plugins;

    public Eclipse(){
        this.plugins = new ArrayList<>();
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        return deepClone();
    }

    private Object deepClone() {
        ByteArrayOutputStream bos = null;
        ObjectOutputStream oos = null;
        try {
            bos = new ByteArrayOutputStream();
            oos = new ObjectOutputStream(bos);
            oos.writeObject(this);
            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
            ObjectInputStream ois = new ObjectInputStream(bis);
            return (Eclipse) ois.readObject();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            if (bos != null) {
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (oos != null) {
                try {
                    oos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public String getOfficialWebsite() {
        return officialWebsite;
    }

    public void setOfficialWebsite(String officialWebsite) {
        this.officialWebsite = officialWebsite;
    }

    public List<Plugin> getPlugins() {
        return plugins;
    }

    public void setPlugins(List<Plugin> plugins) {
        this.plugins = plugins;
    }
}
